<!-- 辅助器具管理 -->
<template>
  <el-card>
    <el-row>
      <el-form ref="form" :model="searchDto" inline label-suffix=":">
        <el-form-item label="关键字" prop="assistEquName">
          <el-input
            v-model="searchDto.assistEquName"
            placeholder="请输入器具名称"
            style="width:250px"
          ></el-input>
        </el-form-item>
        <el-form-item label="残疾类别" prop="disabledTypeId" label-width="90px">
          <el-select v-model="searchDto.disabledTypeId" placeholder="请选择残疾类别">
            <el-option
              v-for="item in getDictionary('DIS_TYPE')"
              :key="item.id"
              :label="item.label"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="器具分类" prop="cid" label-width="90px">
          <el-select v-model="searchDto.cid" placeholder="请选择器具分类">
            <el-option
              v-for="item in getDictionary('ASSIST_EQU_CATEGOTY')"
              :key="item.id"
              :label="item.label"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" type="primary" @click="search">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-s-open" type="primary" @click="clear">重置</el-button>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-plus" type="primary" @click="addAppliance">新建辅助器具</el-button>
        </el-form-item>
      </el-form>
    </el-row>

    <page-table
      ref="recovery"
      :page-data="pageData"
      :loading="loading"
      :do-get-page-data="getPageData"
    >
      <el-table-column type="index" label="编号" width="80" align="center" />
      <el-table-column prop="assistEquName" label="器具名称" align="center" />
      <el-table-column prop="disabledTypeName" label="残疾类别" align="center" />
      <el-table-column prop="categoryName" label="器具分类" align="center" />
      <el-table-column prop="createTime" label="创建时间" align="center" />
      <el-table-column label="操作" align="center" width="300" fixed="right">
        <template slot-scope="scope">
          <el-tooltip content="编辑" placement="top">
            <el-button
              type="button"
              size="mini"
              icon="el-icon-edit"
              @click="editAppliance(scope.row)"
            >
            </el-button>
          </el-tooltip>
          <!--          <el-tooltip content="详情" placement="top">-->
          <!--            <el-button-->
          <!--              type="button"-->
          <!--              size="mini"-->
          <!--              icon="el-icon-view"-->
          <!--              @click="viewDetail(scope.row)"-->
          <!--            >-->
          <!--            </el-button>-->
          <!--          </el-tooltip>-->
          <el-tooltip content="删除" placement="top">
            <el-button
              type="button"
              size="mini"
              icon="el-icon-delete"
              @click="delAppliance(scope.row)"
            >
            </el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </page-table>
  </el-card>
</template>
<script>

export default {
  name: "EqManage",
  data() {
    return {
      pageData: {},
      loading: false,
      searchDto: {
        assistEquName: null,
        disabledTypeId: null,
        cid: null,
      }
    }
  },
  methods: {
    // 获取分页数据
    getPageData(val) {
      let tem = Object.assign(this.searchDto, val);
      this.API.getAssistEquInfoPageList(tem).then(ret => {
        this.pageData = ret.data;
      });
    },

    // 查询
    search() {
      this.getPageData();
    },

    //清空
    clear() {
      this.$refs.form.resetFields()
      this.getPageData();
    },

    editAppliance({ equId: id }) {
      console.log('id:',id)
      this.$router.push({ name: 'eqManageDetail', query: { id } })
    },

    // 新增器具
    addAppliance() {
      this.$router.push({ name: 'eqManageDetail' })
    },

    // 删除
    delAppliance({ equId: id }) {
      this.$confirm("确认删除此器具?", "提示", { type: "warning" }).then(() => {
        this.API.deleteAssistEquInfoById({ id }).then(ret => {
          this.success("删除成功!");
          this.getPageData();
        }).catch(err => {
          this.warning(err)
        });
      });
    }
  },
  mounted() {
    this.getPageData();
  }
};
</script>

<style scoped lang="scss"></style>
